package org.bilinc.gz001;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.JTableHeader;
import java.awt.*;
import java.util.ArrayList;

public class WorkedHeaderRenderer extends DefaultTableCellRenderer {

    public WorkedHeaderRenderer() {
        setHorizontalAlignment(SwingConstants.CENTER);
        setOpaque(true);
        setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    }

    public void updateUI() {
        super.updateUI();
        setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    }

    public Component getTableCellRendererComponent(JTable table, Object value,
                                                   boolean selected, boolean focused, int row, int column) {
        JTableHeader h = (table != null) ? table.getTableHeader() : null;

        if (h != null) {
            setBackground(Color.cyan);
        }
        setValue(value);
        return this;
    }

}